<?php

namespace Pyaf\GymBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ProfesorType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('username')
            ->add('password', 'repeated', array(
                    'type' => 'password',
                    'invalid_message' => 'Los campos de contraseña deben coincidir.',
                    'options' => array('label' => 'Password')))
            ->add('userRoles', 'entity', array(
                    'class'         => 'Pyaf\\GymBundle\\Entity\\Rol',
                    'multiple'  => true,
                    'query_builder' => function ($repositorio) {
                        return $repositorio->createQueryBuilder('p');
                    },
            ))
            ->add('persona', new PersonaType())
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Pyaf\GymBundle\Entity\Profesor'
        ));
    }

    public function getName()
    {
        return 'pyaf_gymbundle_profesortype';
    }
}
